import urllib.request

url = 'http://www.baidu.com'

response = urllib.request.urlopen(url)
print(response.status)
html = response.read()
html = html.decode('utf-8')
print(html)

with open('baidu.html', 'w', encoding = 'utf-8') as file:
    file.write(html)